<!DOCTYPE html>
<head>
<script type='text/javascript' src="./jquery.min.js"></script>
</head>
<body>
<div id="message"></div>

<script type="text/javascript">  
$.fn.createWebSocket = function () {
  if ("WebSocket" in window)
  {
     alert("WebSocket is supported by your Browser!");
     // Let us open a web socket
     var ws = new WebSocket("ws://localhost:8888/start");
     ws.onopen = function()
     {
        // Web Socket is connected, send data using send()
        ws.send("Message to send");
     };
     ws.onmessage = function (evt) 
     { 
        var received_msg = evt.data;
        this.html(received_msg);
     };
     ws.onclose = function()
     { 
        // websocket is closed.
     };
  }
  else
  {
     // The browser doesn't support WebSocket
     alert("WebSocket NOT supported by your Browser!");
  }
};

$("#message").createWebSocket();
</script>
</body>
</html>
